package com.hz.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hz.web.entity.LinkEntity;
import com.hz.web.service.IlinkService;
/**
 * 功能链接controller
 * @author Administrator
 *
 */
@Controller
@RequestMapping("link")
public class LinkController {

	@Resource
	private IlinkService linkService;
	
	/**
	 * 查询数据
	 * @param entity
	 * @param page
	 * @param rows
	 * @return
	 */
	@RequestMapping("queryLink")
	@ResponseBody
	public Map<String, Object> queryLink(LinkEntity entity, Integer page,
			Integer rows) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		//结果集合
		List<LinkEntity> ls = linkService.queryLink(entity, page, rows);
		int count = linkService.queryLinkCount(entity);
		resultMap.put("rows", ls);
		resultMap.put("total", count);
		return resultMap;
	}
	
	/**
	 * 修改数据
	 * @param entity
	 * @return
	 */
	@RequestMapping("updateLink")
	@ResponseBody
	public Map<String, Object> updateLink(LinkEntity entity){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		int row = linkService.updateLink(entity);
		resultMap.put("row", row);
		return resultMap;
	}
	
	/**
	 * 添加数据
	 * @param entity
	 * @return
	 */
	@RequestMapping("addLink")
	@ResponseBody
	public Map<String, Object> addLink(LinkEntity entity) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		int row= linkService.addLink(entity);
		resultMap.put("row", row);
		return resultMap;
	}
	
	
}
